from django.forms import ModelForm, CharField, EmailField, IntegerField
from django import forms
from .models import ProductModel, GameProgressModel
from WebApps.Auth.models import AccountModel, PermissionModel, RoleModel


class ProductForm(ModelForm):
    id = CharField(required=False, max_length=255)

    class Meta:
        model = ProductModel
        fields = ['name',
                  'status',
                  'img_screen',
                  'img_order',
                  'img_confirm',
                  'img_recom_1',
                  'img_recom_2',
                  'url',
                  'recommended_value']


class GameProgressForm(ModelForm):
    class Meta:
        model = GameProgressModel
        fields = ['uid', 'progress', 'gid']


class UserForm(ModelForm):
    # id = CharField(max_length=255, required=False)
    create_time = CharField(max_length=255, required=False)

    class Meta:
        model = AccountModel
        # fields = '__all__'
        fields = ['username', 'email', 'password', 'role']


class RoleForm(ModelForm):
    # id = IntegerField(required=False)
    create_time = CharField(required=False, max_length=50)
    class Meta:
        model = RoleModel
        fields = ['role', 'description', 'permissions']


class PermissionForm(ModelForm):
    id = IntegerField(required=False)
    # creator = CharField(max_length=255, required=False)
    create_time = CharField(max_length=50, required=False)

    def __init__(self, *args, **kwargs):
        super(PermissionForm, self).__init__(*args, **kwargs)

    class Meta:
        model = PermissionModel
        fields = ['code', 'name', 'creator']
